/*
 * (C) Copyright 2023 orchy
 * This file is licensed under the BSD-3-Clause license.
 * <https://spdx.org/licenses/BSD-3-Clause.html>
 */
#ifndef _STDINT_H
#define _STDINT_H

// # 7.18.1
// ## 7.18.1.1
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed long long int int64_t;

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;

// ## 7.18.1.2
typedef signed char int_least8_t;
typedef signed short int_least16_t;
typedef signed int int_least32_t;
typedef signed long long int int_least64_t;

typedef unsigned char uint_least8_t;
typedef unsigned short uint_least16_t;
typedef unsigned int uint_least32_t;
typedef unsigned long long int uint_least64_t;

// ## 7.18.1.3
typedef signed char int_fast8_t;
typedef signed short int_fast16_t;
typedef signed int int_fast32_t;
typedef signed long long int int_fast64_t;

typedef unsigned char uint_fast8_t;
typedef unsigned short uint_fast16_t;
typedef unsigned int uint_fast32_t;
typedef unsigned long long int uint_fast64_t;

// ## 7.18.1.4
typedef signed long long int intptr_t;
typedef unsigned long long int uintptr_t;

// ## 7.18.1.5
typedef signed long long int intmax_t;
typedef unsigned long long int uintmax_t;

// # 7.18.2
// ## 7.18.2.1
#define INT8_MIN (-128)
#define INT16_MIN (-32768)
#define INT32_MIN (-2147483648)
#define INT64_MIN (-9223372036854775808)

#define INT8_MAX (127)
#define INT16_MAX (32767)
#define INT32_MAX (2147483647)
#define INT64_MAX (9223372036854775807)

#define UINT8_MAX (255)
#define UINT16_MAX (65535)
#define UINT32_MAX (4294967295)
#define UINT64_MAX (18446744073709551615)

// ## 7.18.2.1
#define INT_LEAST8_MIN (-127)
#define INT_LEAST16_MIN (-32767)
#define INT_LEAST32_MIN (-2147483647)
#define INT_LEAST64_MIN (-9223372036854775807)

#define INT_LEAST8_MAX (127)
#define INT_LEAST16_MAX (32767)
#define INT_LEAST32_MAX (2147483647)
#define INT_LEAST64_MAX (9223372036854775807)

#define UINT_LEAST8_MAX (255)
#define UINT_LEAST16_MAX (65535)
#define UINT_LEAST32_MAX (4294967295)
#define UINT_LEAST64_MAX (18446744073709551615)

// ## 7.18.2.3
#define INT_FAST8_MIN (-127)
#define INT_FAST16_MIN (-32767)
#define INT_FAST32_MIN (-2147483647)
#define INT_FAST64_MIN (-9223372036854775807)

#define INT_FAST8_MAX (127)
#define INT_FAST16_MAX (32767)
#define INT_FAST32_MAX (2147483647)
#define INT_FAST64_MAX (9223372036854775807)

#define UINT_FAST8_MAX (255)
#define UINT_FAST16_MAX (65535)
#define UINT_FAST32_MAX (4294967295)
#define UINT_FAST64_MAX (18446744073709551615)

// ## 7.18.2.4
#define INTPTR_MIN (-32767)
#define INTPTR_MAX (32767)
#define UINTPTR_MAX (65535)

// ## 7.18.2.5
#define INTMAX_MIN (-9223372036854775807)
#define INTMAX_MAX (9223372036854775807)
#define UINTMAX_MAX (18446744073709551615)

// # 7.18.3
// ## 7.18.3.2
#define PTRDIFF_MIN (-65535)
#define PTRDIFF_MAX (65535)
#define SIG_ATOMIC_MIN (-2147483648)
#define SIG_ATOMIC_MAX (2147483647)
#define SIZE_MAX (65535)
#ifndef WCHAR_MIN
  #define WCHAR_MIN (-2147483648)
  #define WCHAR_MAX (2147483647)
#endif
#define WINT_MIN (-2147483648)
#define WINT_MAX (2147483647)

// # 7.18.4
// ## 7.18.4.1
#define INT8_C(x) (x)
#define INT16_C(x) (x)
#define INT32_C(x) (x)
#define INT64_C(x) (x)

#define UINT8_C(x) (x)
#define UINT16_C(x) (x)
#define UINT32_C(x) (x)
#define UINT64_C(x) (x)

// ## 7.18.4.2
#define INTMAX_C(x) (x)
#define UINTMAX_C(x) (x)

#endif
